<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="author" content="order by dede58.com"/>
    <title>登录</title>
    <link rel="stylesheet" type="text/css" href="./css/login.css">

</head>
<body style="background-color: white">
<!-- login -->

<div class="top center">
    <div class="logo center">

    </div>
</div>
    <div class="login" style="text-align: center;margin-left: 37%">
        <div class="login_center" style="width: 90%">
            <div class="login_top">
                <div class="left fl">online登录</div>
                <div class="right fr">还不是online用户？<a href="./register.html" target="_self">立即注册</a></div>
                <div class="clear"></div>
                <div class="xian center"></div>
            </div>
            <div class="login_main center">
                <div class="username">学&nbsp;&nbsp;&nbsp;&nbsp;号:&nbsp;<input id="schoolNumber" class="shurukuang" type="text" name="username"placeholder="请输入你的用户名"/></div>
                <!--<div class="username">学&nbsp;&nbsp;&nbsp;&nbsp;号:&nbsp;<input id="schoolNumber" class="shurukuang" type="text" name="username"placeholder="请输入你的学号"/></div>-->
                <div class="username">密&nbsp;&nbsp;&nbsp;&nbsp;码:&nbsp;<input id="schoolPassword" class="shurukuang" type="password" name="password" placeholder="请输入你的密码"/></div>
                <!--<div class="username">确认密码:&nbsp;<input class="shurukuang" type="password" name="password" placeholder="请再输入一次你的密码"/></div>-->
            </div>
            <div class="login_submit">
                <input class="submit" onclick="login()" type="submit" name="submit" value="立即登录">
            </div>

        </div>
    </div>


<footer>
    <div class="copyright">copyright@ 2018 online</div>
</footer>
</body>
<script src="js/crabapple.js"></script>
<script>

clearAllCookie()        //清空所有cookie
function login() {
    let schoolNumber=document.getElementById('schoolNumber').value
    let schoolPassword=document.getElementById('schoolPassword').value

    let xmlhttplogin = new XMLHttpRequest();
    xmlhttplogin.onreadystatechange = function () {
        if (xmlhttplogin.readyState == 4 && xmlhttplogin.status == 200) {
            let re = JSON.parse(xmlhttplogin.responseText);

            if(re.success==true){
                setCookie('userId',re.user.userId,1)
                setCookie('userImg',re.user.userImg,1)
                setCookie('userName',re.user.userName,1)
                setCookie('qq',re.user.qq,1)
                setCookie('introduceMyself',re.user.introduceMyself,1)
                setCookie('prosecutions',re.user.prosecutions,1)
                setCookie('reputation',re.user.reputation,1)
                setCookie('schoolNumber',re.user.schoolNumber,1)
                setCookie('telephone',re.user.telephone,1)
                window.location.href = 'index.html';
            }
            else alert(re.errMsg)
        }
    }
    xmlhttplogin.open("GET", prime_url+'user/showuserpageinfo?'+'schoolNumber='+schoolNumber+'&schoolPassword='+schoolPassword, true);
    xmlhttplogin.setRequestHeader('Content-Type', 'application/json')
    // xmlhttplogin.send(JSON.stringify({"day": req_day, "offset": req_offset}));
    xmlhttplogin.send();
}


</script>
</html>